home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / util / moni / Scout-src.lha / source / objects / scout_vectors.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-13  |  9.8 KB  |  202 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "system_headers.h"
  31.  
  32. void ClearResetVectors (void) {
  33.    SysBase->ColdCapture = NULL;
  34.    SysBase->CoolCapture = NULL;
  35.    SysBase->WarmCapture = NULL;
  36.    SysBase->KickMemPtr = NULL;
  37.    SysBase->KickTagPtr = NULL;
  38.    SysBase->KickCheckSum = NULL;
  39. }
  40.  
  41. void PrintVectors (char *filename) {
  42.    char  *VBR;
  43.    BPTR  handle;
  44.  
  45.    VBR = (char *) GetVBR ();
  46.  
  47.    handle = HandlePrintStart (filename);
  48.    if (handle) {
  49.       if (clientstate) {
  50.          char  tmpbuffer[256];
  51.  
  52.          if (SendDaemon ("Vectors")) {
  53.             while ((sgets (client_socket, tmpbuffer, 256)) \
  54.               && (strcmp (tmpbuffer, CMD_DONE)) \
  55.               && (strcmp (tmpbuffer, CMD_ERROR))) {
  56.                PrintOneLine (handle, tmpbuffer);
  57.             }
  58.          }
  59.       } else {
  60.          if (PrintOneLine (handle, "\nReset Vectors:\n\n")) {
  61.             _sprintf (tmpstr2, " %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n", "ColdCapture:",SysBase->ColdCapture,"KickMemPtr:",SysBase->KickMemPtr,"CoolCapture:",SysBase->CoolCapture,"KickTagPtr:",SysBase->KickTagPtr,"WarmCapture:",SysBase->WarmCapture,"KickCheckSum:",SysBase->KickCheckSum);
  62.             PrintOneLine (handle, tmpstr2);
  63.  
  64.             PrintOneLine (handle, "\nAuto Vector Interrupts:\n\n");
  65.  
  66.             _sprintf (tmpstr2, " %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx\n", "Level1 ($0064):",*((ULONG *) (VBR + 0x0064)),"Level5 ($0074):",*((ULONG *) (VBR + 0x0074)),"Level2 ($0068):",*((ULONG *) (VBR + 0x0068)),"Level6 ($0078):",*((ULONG *) (VBR + 0x0078)),"Level3 ($006c):",*((ULONG *) (VBR + 0x006c)),"Level7 ($007c):",*((ULONG *) (VBR + 0x007c)),"Level4 ($0070):",*((ULONG *) (VBR + 0x0070)));
  67.             PrintOneLine (handle, tmpstr2);
  68.  
  69.             PrintOneLine (handle, "\nInterrupt Vectors:\n\n");
  70.  
  71.             _sprintf (tmpstr2, " %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n", "TBE  0:",SysBase->IntVects[0].iv_Code,"AUDIO1  8:",SysBase->IntVects[8].iv_Code,"DSKBLK  1:",SysBase->IntVects[1].iv_Code,"AUDIO2  9:",SysBase->IntVects[9].iv_Code,"SOFTINT  2:",SysBase->IntVects[2].iv_Code,"AUDIO3 10:",SysBase->IntVects[10].iv_Code,"PORTS  3:",SysBase->IntVects[3].iv_Code,"RBF 11:",SysBase->IntVects[11].iv_Code);
  72.             PrintOneLine (handle, tmpstr2);
  73.  
  74.             _sprintf (tmpstr2, " %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n %18s $%08lx %18s $%08lx\n", "COPPER  4:",SysBase->IntVects[4].iv_Code,"DSKSYNC 12:",SysBase->IntVects[12].iv_Code,"VERTB  5:",SysBase->IntVects[5].iv_Code,"EXTER 13:",SysBase->IntVects[13].iv_Code,"BLITTER  6:",SysBase->IntVects[6].iv_Code,"INTEN 14:",SysBase->IntVects[14].iv_Code,"AUDIO0  7:",SysBase->IntVects[7].iv_Code,"NMI 15:",SysBase->IntVects[15].iv_Code);
  75.             PrintOneLine (handle, tmpstr2);
  76.          }
  77.       }
  78.    }
  79.    HandlePrintStop();
  80. }
  81.  
  82. void GetVectors (void) {
  83.    char  *VBR;
  84.  
  85.    if (clientstate) {
  86.       char  tmpbuffer[256];
  87.  
  88.       if (SendDaemon ("GetVectorList")) {
  89.          if (sgets (client_socket, tmpbuffer, 256)) {
  90.             MySetContents (vectext1, tmpbuffer);
  91.             if (sgets (client_socket, tmpbuffer, 256)) {
  92.                MySetContents (vectext2, tmpbuffer);
  93.                if (sgets (client_socket, tmpbuffer, 256)) {
  94.                   MySetContents (vectext3, tmpbuffer);
  95.                   if (sgets (client_socket, tmpbuffer, 256)) {
  96.                      MySetContents (vectext4, tmpbuffer);
  97.                      if (sgets (client_socket, tmpbuffer, 256)) {
  98.                         strcmp (tmpbuffer, CMD_DONE);
  99.                      }
  100.                   }
  101.                }
  102.             }
  103.          }
  104.       }
  105.    } else {
  106.       VBR = (char *) GetVBR ();
  107.  
  108.       MySetContents (vectext1, ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->ColdCapture,SysBase->CoolCapture,SysBase->WarmCapture,SysBase->KickMemPtr,SysBase->KickTagPtr,SysBase->KickCheckSum);
  109.       MySetContents (vectext2, ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",*((ULONG *) (VBR + 0x0064)),*((ULONG *) (VBR + 0x0068)),*((ULONG *) (VBR + 0x006c)),*((ULONG *) (VBR + 0x0070)),*((ULONG *) (VBR + 0x0074)),*((ULONG *) (VBR + 0x0078)),*((ULONG *) (VBR + 0x007c)));
  110.       MySetContents (vectext3, ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->IntVects[0].iv_Code,SysBase->IntVects[1].iv_Code,SysBase->IntVects[2].iv_Code,SysBase->IntVects[3].iv_Code,SysBase->IntVects[4].iv_Code,SysBase->IntVects[5].iv_Code,SysBase->IntVects[6].iv_Code,SysBase->IntVects[7].iv_Code);
  111.       MySetContents (vectext4, ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->IntVects[8].iv_Code,SysBase->IntVects[9].iv_Code,SysBase->IntVects[10].iv_Code,SysBase->IntVects[11].iv_Code,SysBase->IntVects[12].iv_Code,SysBase->IntVects[13].iv_Code,SysBase->IntVects[14].iv_Code,SysBase->IntVects[15].iv_Code);
  112.    }
  113. }
  114.  
  115. void SendVectorList (void) {
  116.    char  *VBR;
  117.  
  118.    VBR = (char *) GetVBR ();
  119.  
  120.    SendClient (ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->ColdCapture,SysBase->CoolCapture,SysBase->WarmCapture,SysBase->KickMemPtr,SysBase->KickTagPtr,SysBase->KickCheckSum);
  121.    SendClient (ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",*((ULONG *) (VBR + 0x0064)),*((ULONG *) (VBR + 0x0068)),*((ULONG *) (VBR + 0x006c)),*((ULONG *) (VBR + 0x0070)),*((ULONG *) (VBR + 0x0074)),*((ULONG *) (VBR + 0x0078)),*((ULONG *) (VBR + 0x007c)));
  122.    SendClient (ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->IntVects[0].iv_Code,SysBase->IntVects[1].iv_Code,SysBase->IntVects[2].iv_Code,SysBase->IntVects[3].iv_Code,SysBase->IntVects[4].iv_Code,SysBase->IntVects[5].iv_Code,SysBase->IntVects[6].iv_Code,SysBase->IntVects[7].iv_Code);
  123.    SendClient (ESC "r$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx\n$%08lx",SysBase->IntVects[8].iv_Code,SysBase->IntVects[9].iv_Code,SysBase->IntVects[10].iv_Code,SysBase->IntVects[11].iv_Code,SysBase->IntVects[12].iv_Code,SysBase->IntVects[13].iv_Code,SysBase->IntVects[14].iv_Code,SysBase->IntVects[15].iv_Code);
  124. }
  125.  
  126.  
  127. char vectors_title[WINDOWTITLELEN];
  128. static char *VectorPages[] = { "ResetVecs","AutoVecInts","IntVecs",NULL };
  129.  
  130. void VectorsWindow (BOOL state) {
  131.    if (state) {
  132.       if (WI_Vectors) {
  133.          GetVectors();
  134.       } else {
  135.          WI_Vectors = WindowObject,
  136.          MUIA_Window_Title, MyGetWindowTitle (vectors_title, "VECTORS"),
  137.          MUIA_HelpNode, VectorsText,
  138.          MUIA_Window_ID, MakeListID('V','E','C','T'),
  139.          WindowContents, VGroup,
  140.  
  141.             Child, RegisterGroup(VectorPages),
  142.  
  143.                Child, HGroup,
  144.                   GroupFrameT("Reset Vectors"),
  145.                   Child, HGroup,
  146.                      Child, MyLabel2 (ESC "rColdCapture:\nCoolCapture:\nWarmCapture:\nKickMemPtr:\nKickTagPtr:\nKickCheckSum:"),
  147.                      Child, vectext1 = MyTextObject2(),
  148.                   End,
  149.                End,
  150.  
  151.                Child, HGroup,
  152.                   GroupFrameT("Auto Vector Interrupts"),
  153.                   Child, HGroup,
  154.                      Child, MyLabel2 (ESC "rLevel1 ($0064):\nLevel2 ($0068):\nLevel3 ($006c):\nLevel4 ($0070):\nLevel5 ($0074):\nLevel6 ($0078):\nLevel7 ($007c):"),
  155.                      Child, vectext2 = MyTextObject2(),
  156.                   End,
  157.                End,
  158.  
  159.                Child, HGroup,
  160.                   GroupFrameT("Interrupt Vectors"),
  161.                   Child, HGroup,
  162.                      Child, MyLabel (ESC "rTBE\nDSKBLK\nSOFTINT\nPORTS\nCOPPER\nVERTB\nBLITTER\nAUDIO0"),
  163.                      Child, MyLabel (ESC "r 0:\n1:\n2:\n3:\n4:\n5:\n6:\n7:"),
  164.                      Child, vectext3 = MyTextObject2(),
  165.                   End,
  166.                   Child, HGroup,
  167.                      Child, MyLabel (ESC "rAUDIO1\nAUDIO2\nAUDIO3\nRBF\nDSKSYNC\nEXTER\nINTEN\nNMI"),
  168.                      Child, MyLabel (ESC "r8:\n9:\n10:\n11:\n12:\n13:\n14:\n15:"),
  169.                      Child, vectext4 = MyTextObject2(),
  170.                   End,
  171.                End,
  172.             End,
  173. #ifndef WINDOW_PROBLEMS
  174.             Child, MyVSpace(4),
  175. #endif
  176.             Child, HGroup, MUIA_Group_SameSize, TRUE,
  177.                Child, BT_VecUpdate = KeyButtonA (UpdateText,ID_VECUPDATE),
  178.                Child, BT_VecPrint  = KeyButtonA (PrintText ,ID_VECPRINT),
  179.                Child, BT_VecExit   = KeyButtonA (ExitText  ,ID_VECEXIT),
  180.             End,
  181.          End, End;
  182.  
  183.          DoMethod (AP_Scout,OM_ADDMEMBER,WI_Vectors);
  184.          DoMethod (WI_Vectors,MUIM_Window_SetCycleChain,BT_VecUpdate,BT_VecPrint,BT_VecExit,NULL);
  185.          SetCloseRequest (WI_Vectors,ID_VECEXIT);
  186.  
  187.          GetVectors();
  188.  
  189.          SetWindowOpen (WI_Vectors,NULL,ID_VECEXIT);
  190.       }
  191.    } else if ((! state) && (WI_Vectors)) {
  192.       SetWindowClose (WI_Vectors,TRUE);
  193.  
  194. //      FreeVectors();
  195.  
  196.       DoMethod (AP_Scout,OM_REMMEMBER,WI_Vectors);
  197.       MUI_DisposeObject (WI_Vectors);
  198.       WI_Vectors = NULL;
  199.    }
  200. }
  201.  
  202.